<template>
  <div>
    我是B组件(发送方)
    <button @click="send">发送按钮</button>
  </div>
</template>

<script>
// 1. 创建一个空Vue实例，作为事件总线
import Bus from "../utils/EventBus";
export default {
  methods: {
    // 3. 触发Bus监听的sendMsg事件，利用$emit发送消息
    send() {
      Bus.$emit("sendMsg", "aa");
    }
  }
};
</script>

<style scoped>
div {
  width: 150px;
  height: 80px;
  border: 3px solid #000;
  padding: 10px;
  margin: 10px;
}
</style>